home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / tcp / amitcp / amitcp-api-22.lha / AmiTCP-2.2 / doc / bsdsocket.doc next >
Encoding:
Text File  |  1993-10-20  |  69.2 KB  |  1,901 lines

  1. TABLE OF CONTENTS
  2.  
  3. bsdsocket.library/CloseSocket
  4. bsdsocket.library/Dup2Socket
  5. bsdsocket.library/Errno
  6. bsdsocket.library/Inet_LnaOf
  7. bsdsocket.library/Inet_NetOf
  8. bsdsocket.library/Inet_NtoA
  9. bsdsocket.library/IoctlSocket
  10. bsdsocket.library/ObtainSocket
  11. bsdsocket.library/ReleaseCopyOfSocket
  12. bsdsocket.library/ReleaseSocket
  13. bsdsocket.library/SetDTableSize
  14. bsdsocket.library/SetErrnoPtr
  15. bsdsocket.library/SetSocketSignals
  16. bsdsocket.library/Syslog
  17. bsdsocket.library/accept
  18. bsdsocket.library/bind
  19. bsdsocket.library/connect
  20. bsdsocket.library/getdtablesize
  21. bsdsocket.library/gethostbyaddr
  22. bsdsocket.library/gethostbyname
  23. bsdsocket.library/getnetbyaddr
  24. bsdsocket.library/getnetbyname
  25. bsdsocket.library/getpeername
  26. bsdsocket.library/getprotobyname
  27. bsdsocket.library/getprotobynumber
  28. bsdsocket.library/getservbyname
  29. bsdsocket.library/getservbyport
  30. bsdsocket.library/getsockname
  31. bsdsocket.library/getsockopt
  32. bsdsocket.library/inet_MakeAddr
  33. bsdsocket.library/inet_addr
  34. bsdsocket.library/inet_lnaof
  35. bsdsocket.library/inet_makeaddr
  36. bsdsocket.library/inet_netof
  37. bsdsocket.library/inet_network
  38. bsdsocket.library/inet_ntoa
  39. bsdsocket.library/listen
  40. bsdsocket.library/recv
  41. bsdsocket.library/recvfrom
  42. bsdsocket.library/select
  43. bsdsocket.library/send
  44. bsdsocket.library/sendto
  45. bsdsocket.library/setsockopt
  46. bsdsocket.library/shutdown
  47. bsdsocket.library/socket
  48. bsdsocket.library/CloseSocket                    bsdsocket.library/CloseSocket
  49.  
  50.    NAME
  51.         CloseSocket - delete a socket descriptor
  52.  
  53.    SYNOPSIS
  54.         success = CloseSocket(s)
  55.         D0                    D0
  56.  
  57.         long CloseSocket(long);
  58.  
  59.    FUNCTION 
  60.         CloseSocket() deletes  a  descriptor  from the  library base
  61.         socket reference table.   If s is the last reference  to the
  62.         underlying object, then the object  will  be deactivated and
  63.         socket  (see socket()),  associated naming  information  and
  64.         queued data are discarded.
  65.  
  66.         All sockets are automatically closed when the socket library
  67.         is closed, but closing sockets as soon as possible is
  68.         recommended to save system resources.
  69.  
  70.    RETURN VALUES
  71.          0   on success.
  72.  
  73.         -1   on failure and sets errno to indicate the error.
  74.  
  75.    ERRORS
  76.         EBADF             - s is not an active socket descriptor.
  77.  
  78.         EINTR             - linger on close was interrupted.
  79.                             The socket is closed, however.
  80.  
  81.    SEE ALSO
  82.         accept(), SetSocketSignals(), shutdown(), socket(),
  83.         exec.library/CloseLibrary()
  84. bsdsocket.library/Dup2Socket                      bsdsocket.library/Dup2Socket
  85.  
  86.    NAME
  87.        Dup2Socket - duplicate a socket descriptor
  88.  
  89.    SYNOPSIS
  90.  
  91.        newfd = Dup2Socket(fd1, fd2)
  92.        D0                 D0   D1
  93.  
  94.        long Dup2Socket(long, long);
  95.  
  96.    DESCRIPTION
  97.        Dup2Socket() duplicates an existing socket descriptor. 
  98.        the argument fd1 is small non-negative value that indexes
  99.        the socket on SocketBase descriptor table. The value must
  100.        be less than the size of the table, which is returned by
  101.        getdtablesize(). fd2 specifies the desired value of the new
  102.        descriptor. If descriptor fd2 is already in use, it is 
  103.        first deallocated as if it were closed by CloseSocket(). If
  104.        the value if fd2 is -1, the new descriptor used and returned
  105.        is the lowest numbered descriptor that is not currently in 
  106.        use by the SocketBase.
  107.  
  108.    RETURN VALUES
  109.        Dup2Socket() returns a new descriptor on  success. On failure
  110.        -1 is returned and errno is set to indicate the error.
  111.  
  112.    ERRORS
  113.        EBADF          fd1 or fd2 is not a valid active descriptor.
  114.  
  115.        EMFILE         Too many descriptors are active.
  116.  
  117.    SEE ALSO
  118.        accept(), CloseSocket(), getdtablesize(), SetDtableSize(), 
  119.        socket()
  120.  
  121. bsdsocket.library/Errno                                bsdsocket.library/Errno
  122.  
  123.    NAME
  124.         Errno - get error value after unsuccessful function call
  125.  
  126.    SYNOPSIS
  127.         errno = Errno()
  128.         D0
  129.  
  130.         LONG Errno(VOID);
  131.  
  132.    FUNCTION
  133.         When  some  function  in  socket  library  return  an  error
  134.         condition value, they also set a specific error value.  This
  135.         error value can be extracted by this function.
  136.  
  137.    RESULT
  138.         Error value  indicating  the error on  last failure  of some
  139.         socket function call.
  140.  
  141.    NOTES
  142.         Return  value  of  Errno()  is not changed  after successful
  143.         function so so it cannot be used to determine success of any
  144.         function call  of this library.  Also, another function call
  145.         to this  library may change  the return value of  Errno() so
  146.         use it right after error occurred.
  147.  
  148.    SEE ALSO
  149.         SetErrnoPtr()
  150.  
  151. bsdsocket.library/Inet_LnaOf                      bsdsocket.library/Inet_LnaOf
  152.  
  153.    SEE ALSO
  154.        inet_addr()
  155.  
  156. bsdsocket.library/Inet_NetOf                      bsdsocket.library/Inet_NetOf
  157.  
  158.    SEE ALSO
  159.        inet_addr()
  160.  
  161. bsdsocket.library/Inet_NtoA                        bsdsocket.library/Inet_NtoA
  162.  
  163.    SEE ALSO
  164.        inet_addr()
  165.  
  166. bsdsocket.library/IoctlSocket                    bsdsocket.library/IoctlSocket
  167.  
  168.    NAME
  169.         IoctlSocket - control sockets
  170.  
  171.    SYNOPSIS
  172.  
  173.         #include <sys/types.h>
  174.         #include <sys/ioctl.h>
  175.  
  176.         value = IoctlSocket(fd, request, arg)
  177.         D0            D0  D1       A0
  178.  
  179.         long IoctlSocket(long, long, caddr_t);
  180.  
  181.    FUNCTION
  182.         IoctlSocket() performs a special function on the object referred
  183.         to by the open  socket descriptor fd. Note: the setsockopt()
  184.         call (see getsockopt()) is the primary  method for operating
  185.         on sockets  as such, rather than on the underlying  protocol
  186.         or network interface.
  187.  
  188.         For most IoctlSocket() functions, arg is a pointer to data to
  189.         be used by the  function  or to be filled in by the function.
  190.         Other functions may ignore arg or may treat it directly as a
  191.         data item; they may, for example, be passed an int value.
  192.  
  193.         The following requests are supported:
  194.  
  195.  
  196.         FIOASYNC            The argument is a  pointer  to  a  long.
  197.                             Set  or  clear asynchronous I/O.  If the
  198.                             value of that  long is  a  1  (one)  the
  199.                             descriptor  is set for asynchronous I/O.
  200.                             If the value of that long is a  0 (zero)
  201.                             the  descriptor is cleared for asynchro-
  202.                             nous I/O.
  203.  
  204.         FIOCLEX
  205.         FIONCLEX            Ignored, no use for close-on-exec flag
  206.                             in Amiga.
  207.  
  208.         FIOGETOWN
  209.         SIOCGPGRP           The argument is pointer to struct Task*.
  210.                             Set the value of that pointer to the 
  211.                             Task that  is  receiving SIGIO or SIGURG
  212.                             signals for  the  socket  referred to by
  213.                             the descriptor passed to IoctlSocket().
  214.  
  215.         FIONBIO             The argument is a  pointer  to  a  long.
  216.                             Set  or  clear non-blocking I/O.  If the
  217.                             value of that  long is  a  1  (one)  the
  218.                             descriptor  is set for non-blocking I/O.
  219.                             If the value of that long is a  0 (zero)
  220.                             the   descriptor  is  cleared  for  non-
  221.                             blocking I/O.
  222.  
  223.         FIONREAD            The argument is a  pointer  to  a  long.
  224.                             Set the value of that long to the number
  225.                             of immediately readable characters  from
  226.                             the socket fd.
  227.  
  228.         FIOSETOWN
  229.         SIOCSPGRP           The argument is pointer to struct Task*,
  230.                             pointer  to  the task  that will subseq-
  231.                             uently receive  SIGIO or  SIGURG signals
  232.                             for   the  socket  referred  to  by  the
  233.                             descriptor passed.
  234.  
  235.         SIOCCATMARK         The argument is a pointer to a long.
  236.                             Set the value of that long to 1 if the
  237.                             read pointer for the socket referred to
  238.                             by the descriptor passed to
  239.                             IoctlSocket() points to a mark in the
  240.                             data stream for an out-of-band message,
  241.                             and to 0 if it does not point to a mark.
  242.  
  243.  
  244.    RETURN VALUES
  245.         IoctlSocket() returns 0 on success for most requests.   Some 
  246.         specialized requests may return non-zero values on success; On  
  247.         failure,  IoctlSocket() returns -1 and sets errno to indicate
  248.         the error.
  249.  
  250.    ERRORS
  251.         EBADF          fd is not a valid descriptor.
  252.  
  253.         EINVAL         request or arg is not valid.
  254.  
  255.         IoctlSocket() will also fail if the object on which the function
  256.         is  being performed detects an error. In this case, an error
  257.         code specific  to  the  object  and  the  function  will  be
  258.         returned.
  259.  
  260.    SEE ALSO
  261.         getsockopt(), SetSocketSignals(), setsockopt()
  262. bsdsocket.library/ObtainSocket                  bsdsocket.library/ObtainSocket
  263.  
  264.    NAME
  265.         ObtainSocket - get a socket from AmiTCP/IP socket list
  266.  
  267.    SYNOPSIS
  268.         s = ObtainSocket(id, domain, type, protocol)
  269.         D0               D0  D1      D2    D3
  270.  
  271.         LONG ObtainSocket(LONG, LONG, LONG, LONG);
  272.  
  273.    FUNCTION 
  274.         When one task wants to give  a socket to  an another one, it
  275.         releases it (with a key value) to a special socket list held
  276.         by  AmiTCP/IP.   This  function  requests  that  socket  and
  277.         receives it if id and other parameters match.
  278.  
  279.    INPUTS
  280.         id       - a key value given by the socket donator.
  281.         domain   - see documentation of socket().
  282.         type     - see documentation of socket().
  283.         protocol - see documentation of socket().
  284.  
  285.    RESULT
  286.         Non negative socket descriptor on success. On failure, -1 is
  287.         returned and the errno is set to indicate the error.
  288.  
  289.    ERRORS
  290.         EMFILE          - The per-process descriptor table is
  291.                           full.
  292.  
  293.         EPROTONOSUPPORT - The protocol type or the specified  pro-
  294.                           tocol is not supported within this
  295.                           domain.
  296.  
  297.         EPROTOTYPE      - The protocol is the wrong type for the
  298.                           socket.
  299.  
  300.         EWOULDBLOCK     - Matching socket is not found.
  301.          
  302.    SEE ALSO
  303.         ReleaseCopyOfSocket(), ReleaseSocket(), socket()
  304.  
  305. bsdsocket.library/ReleaseCopyOfSocket    bsdsocket.library/ReleaseCopyOfSocket
  306.  
  307.    NAME
  308.         ReleaseCopyOfSocket - copy given socket to AmiTCP/IP socket list.
  309.  
  310.    SYNOPSIS
  311.         id = ReleaseCopyOfSocket(fd, id)
  312.         D0                       D0  D1
  313.  
  314.         LONG ReleaseCopyOfSocket(LONG, LONG);
  315.  
  316.    FUNCTION
  317.         Make a new reference to a given socket (pointed by its descriptor)
  318.         and release it to the socket list held by AmiTCP/IP.
  319.  
  320.    INPUTS
  321.         fd - descriptor of the socket to release.
  322.  
  323.         id - the key value to identify use of this socket. It can be
  324.              unique or not, depending on its  value.  If id value is
  325.              between 0  and  65535,  inclusively,  it is  considered
  326.              nonunique  and it can  be  used as a port  number,  for
  327.              example.   If  id is greater  than  65535 and less than
  328.              2^31) it  must be unique in currently  held sockets  in
  329.              AmiTCP/IP socket  list,  Otherwise  an  error  will  be
  330.              returned  and  socket  is  not  released.    If  id  ==
  331.              UNIQUE_ID (defined in <sys/socket.h>) an unique id will
  332.              be generated.
  333.  
  334.    RESULT
  335.         id - -1 in case of error and the key value of the socket put
  336.              in the list. Most useful when an unique id is generated
  337.              by this routine. 
  338.  
  339.    ERRORS
  340.         EINVAL - Requested unique id is already used.
  341.  
  342.         ENOMEM - Needed memory couldn't be allocated.
  343.  
  344.    NOTE
  345.         The socket descriptor is not deallocated.
  346.  
  347.    SEE ALSO
  348.         ObtainSocket(), ReleaseSocket()
  349.  
  350.  
  351. bsdsocket.library/ReleaseSocket                bsdsocket.library/ReleaseSocket
  352.  
  353.    NAME
  354.         ReleaseSocket - release given socket to AmiTCP/IP socket list.
  355.  
  356.    SYNOPSIS
  357.         id = ReleaseSocket(fd, id)
  358.         D0                 D0  D1
  359.  
  360.         LONG ReleaseSocket(LONG, LONG);
  361.  
  362.    FUNCTION
  363.         Release the reference of given socket (via  its  descriptor)
  364.         and move the socket to the  socket  list held by  AmiTCP/IP.
  365.         The socket descriptor is deallocated in this procedure.
  366.  
  367.    INPUTS
  368.         fd - descriptor of the socket to release.
  369.  
  370.         id - the key value to identify use of this socket. It can be
  371.              unique or not, depending on its  value.  If id value is
  372.              between 0  and  65535,  inclusively,  it is  considered
  373.              nonunique  and it can  be  used as a port  number,  for
  374.              example.   If  id is greater  than  65535 and less than
  375.              2^31) it  must be unique in currently  held sockets  in
  376.              AmiTCP/IP socket  list,  Otherwise  an  error  will  be
  377.              returned  and  socket  is  not  released.    If  id  ==
  378.              UNIQUE_ID (defined in <sys/socket.h>) an unique id will
  379.              be generated.
  380.  
  381.    RESULT
  382.         id - -1 in case of error and the key value of the socket put
  383.              in the list. Most useful when an unique id is generated
  384.              by this routine. 
  385.  
  386.    ERRORS
  387.         EINVAL - Requested unique id is already used.
  388.  
  389.         ENOMEM - Needed memory couldn't be allocated.
  390.  
  391.    SEE ALSO
  392.         ObtainSocket(), ReleaseCopyOfSocket()
  393.  
  394. bsdsocket.library/SetDTableSize                bsdsocket.library/SetDTableSize
  395.  
  396.    NAME
  397.         SetDTableSize - set socket descriptor table size of the base
  398.  
  399.    SYNOPSIS
  400.         newsize = SetDTableSize(size)
  401.         D0                      D0
  402.  
  403.         LONG SetDTableSize(UWORD);
  404.  
  405.    FUNCTION
  406.         This  function increases  the  descriptor table size  inside
  407.         library base so more sockets can be open at the same time.
  408.  
  409.    INPUT
  410.         size - the new size of the desctiptor table.
  411.  
  412.    RESULT
  413.         newsize - the new size of the descriptor table. Note that
  414.         this can be less than requested if an error occured.
  415.  
  416.    WARNING
  417.         If the size of fd_set is not adjusted to store the increased
  418.         space needed for  new  socket descriptors some other  memory
  419.         will  be spilled.  Change  the  value of  FD_SETSIZE  before
  420.         including  any  socket  include  files  and  don't  increase
  421.         descriptor  table   to   greater  than  the  new   value  of
  422.         FD_SETSIZE.
  423.  
  424.    SEE ALSO
  425.         getdtablesize(), select()
  426.  
  427. bsdsocket.library/SetErrnoPtr                    bsdsocket.library/SetErrnoPtr
  428.  
  429.    NAME
  430.         SetErrnoPtr - set new place where the error value will be written
  431.  
  432.    SYNOPSIS
  433.         SetErrnoPtr(ptr, size)
  434.                     A0   D0
  435.  
  436.         VOID SetErrnoPtr(VOID *, UBYTE);
  437.  
  438.    FUNCTION
  439.         This functions allows caller to redirect error variable inside
  440.         scope of  caller task.   Usually this is  used to make  task's
  441.         global variable errno as error variable.
  442.  
  443.    INPUTS
  444.         ptr     - pointer to error variable that is to be modified on
  445.                   every error condition on this library function.
  446.         size    - size of the error variable.
  447.  
  448.    EXAMPLE
  449.         #include <errno.h>
  450.  
  451.         struct Library;
  452.         struct Library * SocketBase = NULL;
  453.  
  454.         int main(void)
  455.         {
  456.            ...
  457.           if ((SocketBase = OpenLibrary("bsdsocket.library", 2))
  458.               != NULL) {
  459.             SetErrnoPtr(&errno, sizeof(errno));
  460.            ...
  461.           }
  462.         }
  463.  
  464.    NOTES
  465.         Be sure that this new error variable exists until library base
  466.         is finally closed or SetErrnoPtr() is called again for another
  467.         variable.
  468.  
  469.    SEE ALSO
  470.         Errno()
  471.  
  472. bsdsocket.library/SetSocketSignals          bsdsocket.library/SetSocketSignals
  473.  
  474.    NAME
  475.         SetSocketSignals - inform AmiTCP/IP of INTR, IO and URG signals
  476.  
  477.    SYNOPSIS
  478.         SetSocketSignals(sigintrmask, sigiomask, sigurgmask)
  479.                          D0           D1         D2
  480.  
  481.         VOID SetSocketSignals(ULONG, ULONG, ULONG);
  482.  
  483.    FUNCTION
  484.         SetSocketSignals()  tells the AmiTCP/IP which  signal  masks
  485.         corresponds UNIX SIGINT, SIGIO and SIGURG signals to be used
  486.         in  this  implementation.   sigintrmask  mask   is  used  to
  487.         determine  which  Amiga signals  interrupt  blocking library
  488.         calls.   sigio-  and sigurgmasks  are sent when asynchronous
  489.         notification of socket events is done and  when  out-of-band
  490.         data arrives, respectively.
  491.  
  492.         Note that  the supplied  values write over old ones. If this
  493.         function is used and CTRL-C is still wanted to interrupt the
  494.         calls (the  default behaviour), the value BREAKF_CTRL_C must
  495.         be explicitly given.
  496.  
  497.    SEE ALSO
  498.         IoctlSocket(), recv(), send(), WaitSelect()
  499.  
  500. bsdsocket.library/Syslog                              bsdsocket.library/Syslog
  501.  
  502.    NAME
  503.         syslog - write message to AmiTCP/IP log.
  504.  
  505.    SYNOPSIS
  506.         #include <syslog.h>
  507.  
  508.         void syslog(unsigned long level, char * format, ...); 
  509.  
  510.         Syslog(level, format, ap)
  511.               D0     A0      A1
  512.  
  513.         VOID Syslog(unsigned long, const char *, va_list);
  514.  
  515.  
  516.    FUNCTION
  517.         Writes the message given as format string and arguments
  518.         (printf-style) both to the log file and to the console,
  519.         execpt if the level is LOG_EMERG, which is used by panic(),
  520.         in which case only the log file is used since panic()
  521.         generates a User Request.
  522.  
  523.         The level is selected from an ordered list:
  524.  
  525.              LOG_EMERG           A panic condition.
  526.  
  527.              LOG_ALERT           A condition that should be
  528.                                  corrected immediately, such as a 
  529.                                  corrupted system database.
  530.  
  531.              LOG_CRIT            Critical conditions, such  as  hard
  532.                                  device errors.
  533.  
  534.              LOG_ERR             Errors.
  535.  
  536.              LOG_WARNING         Warning messages.
  537.  
  538.              LOG_NOTICE          Conditions that are not error  con-
  539.                                  ditions,  but that may require spe-
  540.                                  cial handling.
  541.  
  542.              LOG_INFO            Informational messages.
  543.  
  544.              LOG_DEBUG           Messages that  contain  information
  545.                                  normally of use only when debugging
  546.                                  a program.
  547.  
  548.    INPUTS
  549.         Level     - indicates the type of the message. The levels
  550.                     are defined in sys/syslog.h and listed above.
  551.  
  552.         format    - This is a printf-style format string as defined
  553.                     in exec.library/RawDoFmt().
  554.  
  555.         arguments - as in printf().
  556.  
  557.         ap        - pointer to an array of arguments.
  558.  
  559.    RESULT
  560.         Returns no value.
  561.  
  562.    EXAMPLES
  563.         To  log a  message at priority  LOG_INFO, it would  make the
  564.         following call to syslog:
  565.  
  566.              syslog(LOG_INFO,  "Connection from host %s",
  567.                     CallingHost);
  568.  
  569.    NOTES
  570.         As Exec RawDoFmt() used to do formatting expects by default
  571.         short (16 bit long) integers you should use the `l'-modifier
  572.         when appopriate. See your compiler documentation about how
  573.         it passes arguments on a vararg list.
  574.  
  575.         This function is callable from interrupts.
  576.  
  577.    BUGS
  578.         Because there is a limited number of internal messages used
  579.         by the logging system, some log messages may get lost if a
  580.         high priority task or interrupt handler sends many messages
  581.         in succession. If this happens, the next log message tells
  582.         the fact. 
  583.  
  584.    SEE ALSO
  585.        exec.library/RawDoFmt()
  586.  
  587. bsdsocket.library/accept                              bsdsocket.library/accept
  588.  
  589.    NAME
  590.         accept - accept a connection on a socket
  591.  
  592.    SYNOPSIS
  593.         #include <sys/types.h>
  594.         #include <sys/socket.h>
  595.  
  596.         ns = accept(s, addr, addrlen)
  597.         D0          D0 A0    A1
  598.  
  599.         long accept(long, struct sockaddr *, long *);
  600.  
  601.    FUNCTION
  602.         The  argument  s  is a  socket  that  has  been created with
  603.         socket(), bound to an  address  with bind(), and  is listen-
  604.         ing for connections after a listen().  accept() extracts the
  605.         first  connection  on  the  queue  of  pending  connections,
  606.         creates a new socket with the same properties of s and allo-
  607.         cates a new socket descriptor for the socket.  If no pending
  608.         connections are present on the  queue, and the socket is not
  609.         marked  as non-blocking, accept() blocks the caller  until a
  610.         connection is present.  If the socket is marked non-blocking
  611.         and  no  pending  connections  are  present  on  the  queue,
  612.         accept() returns  an error as described below.  The accepted
  613.         socket is used to read and write data to and from the socket
  614.         which connected to  this one; it is not used to  accept more
  615.         connections.  The original socket s remains open for accept-
  616.         ing further connections.
  617.  
  618.         The argument addr is a result parameter that  is  filled  in
  619.         with  the  address of the connecting entity, as known to the
  620.         communications layer.  The exact format of the addr  parame-
  621.         ter  is  determined by the domain in which the communication
  622.         is occurring.  The addrlen is a value-result  parameter;  it
  623.         should  initially  contain the amount of space pointed to by
  624.         addr; on return it will contain the actual length (in bytes)
  625.         of   the   address   returned.    This  call  is  used  with
  626.         connection-based socket types, currently with SOCK_STREAM.
  627.  
  628.         It is possible to select() a socket  for  the  purposes  of
  629.         doing an accept() by selecting it for read.
  630.  
  631.    RETURN VALUES
  632.         accept() returns a non-negative descriptor for the  accepted
  633.         socket on success.  On failure, it returns -1 and sets errno
  634.         to indicate the error.
  635.  
  636.    ERRORS
  637.         EBADF        - The descriptor is invalid.
  638.  
  639.         EINTR        - The operation was interrupted by a break 
  640.                        signal.
  641.  
  642.         EOPNOTSUPP   - The referenced socket is not of type
  643.                        SOCK_STREAM.
  644.  
  645.         EWOULDBLOCK  - The socket is marked non-blocking and no con-
  646.                        nections are present to be accepted.
  647.  
  648.    SEE ALSO
  649.         bind(), connect(), listen(), select(), SetSocketSignals(),
  650.         socket()
  651. bsdsocket.library/bind                                  bsdsocket.library/bind
  652.  
  653.    NAME
  654.         bind - bind a name to a socket
  655.  
  656.    SYNOPSIS
  657.         #include <sys/types.h>
  658.         #include <sys/socket.h>
  659.  
  660.         success = bind(s, name, namelen)
  661.         D0             D0 A0    D1
  662.  
  663.         long bind(long, struct sockaddr *, long);
  664.  
  665.    FUNCTION
  666.         bind() assigns a name to an unnamed socket.  When  a  socket
  667.         is created with socket(2) it exists in a name space (address
  668.         family) but has no name assigned.  bind() requests that  the
  669.         name pointed to by name be assigned to the socket.
  670.  
  671.    RETURN VALUES
  672.         0  - on success.
  673.  
  674.         -1 - on failure and sets errno to indicate the error.
  675.  
  676.    ERRORS
  677.         EACCES            - The requested address is protected,  and
  678.                             the  current user has inadequate permis-
  679.                             sion to access it.
  680.  
  681.         EADDRINUSE        - The specified address is already in use.
  682.  
  683.         EADDRNOTAVAIL     - The specified address is  not  available
  684.                             from the local machine.
  685.  
  686.         EBADF             - s is not a valid descriptor.
  687.  
  688.         EINVAL            - namelen is  not  the  size  of  a  valid
  689.                             address  for  the specified address fam-
  690.                             ily.
  691.  
  692.                             The  socket  is  already  bound  to   an
  693.                             address.
  694.  
  695.    SEE ALSO
  696.         connect(), getsockname(), listen(), socket()
  697.  
  698.    NOTES
  699.         The rules used in name binding  vary  between  communication
  700.         domains.
  701. bsdsocket.library/connect                            bsdsocket.library/connect
  702.  
  703.    NAME
  704.         connect - initiate a connection on a socket
  705.    
  706.    SYNOPSIS
  707.         #include <sys/types.h>
  708.         #include <sys/socket.h>
  709.    
  710.         success = connect(s, name, namelen)
  711.         D0                D0 A0    D1
  712.    
  713.         long connect(long, struct sockaddr *, long);
  714.    
  715.    FUNCTION
  716.         The parameter s is a socket.  If it  is of  type SOCK_DGRAM,
  717.         then  this call specifies the peer with which the  socket is
  718.         to be associated;  this address  is that  to which datagrams
  719.         are  to be sent, and  the only address from which  datagrams
  720.         are to be received.  If it is of type SOCK_STREAM, then this
  721.         call attempts  to make a connection  to another socket.  The
  722.         other socket is specified by name which is an address in the
  723.         communications space of  the  socket.   Each  communications
  724.         space interprets the  name parameter in  its  own way.  Gen-
  725.         erally, stream sockets may successfully connect() only once;
  726.         datagram sockets may use connect() multiple  times to change
  727.         their association.  Datagram sockets may dissolve the  asso-
  728.         ciation by connecting to  an invalid address, such as a null
  729.         address.
  730.    
  731.    RETURN VALUES
  732.          0   on success.
  733.    
  734.         -1   on failure and sets errno to indicate the error.
  735.    
  736.    ERRORS
  737.         EADDRINUSE        - The address is already in use.
  738.    
  739.         EADDRNOTAVAIL     - The specified address is  not  available
  740.                             on the remote machine.
  741.    
  742.         EAFNOSUPPORT      - Addresses in the specified address  fam-
  743.                             ily cannot be used with this socket.
  744.    
  745.         EALREADY          - The socket is non-blocking and a  previ-
  746.                             ous  connection attempt has not yet been
  747.                             completed.
  748.    
  749.         EBADF             - s is not a valid descriptor.
  750.    
  751.         ECONNREFUSED      - The attempt to  connect  was  forcefully
  752.                             rejected.   The  calling  program should
  753.                             CloseSocket() the socket descriptor, and
  754.                             issue another socket()  call to obtain a
  755.                             new descriptor before attempting another
  756.                             connect() call.
  757.    
  758.         EINPROGRESS       - The socket is non-blocking and the  con-
  759.                             nection cannot be completed immediately.
  760.                             It is possible to select()  for  comple-
  761.                             tion  by  selecting the socket for writ-
  762.                             ing.
  763.    
  764.         EINTR             - The operation was interrupted by a break 
  765.                             signal.
  766.  
  767.         EINVAL            - namelen is  not  the  size  of  a  valid
  768.                             address  for  the specified address fam-
  769.                             ily.
  770.    
  771.         EISCONN             The socket is already connected.
  772.    
  773.         ENETUNREACH       - The network is not reachable  from  this
  774.                             host.
  775.    
  776.         ETIMEDOUT         - Connection   establishment   timed   out
  777.                             without establishing a connection.
  778.         
  779.    SEE ALSO
  780.         accept(), CloseSocket(), connect(), getsockname(), select(),
  781.         socket()
  782. bsdsocket.library/getdtablesize                bsdsocket.library/getdtablesize
  783.  
  784.    NAME
  785.         getdtablesize - get socket descriptor table size
  786.  
  787.    SYNOPSIS
  788.  
  789.         nfds = getdtablesize()
  790.         D0
  791.  
  792.         long getdtablesize(void);
  793.  
  794.    FUNCTION
  795.         Return value of maximum  number of open socket  descriptors.
  796.         Larger  socket  descriptor  table  can   be  allocated  with
  797.         SetDTableSize() call.
  798.  
  799.    SEE ALSO
  800.         SetDTableSize()
  801.  
  802. bsdsocket.library/gethostbyaddr                bsdsocket.library/gethostbyaddr
  803.  
  804.    SEE ALSO
  805.         gethostbyname()
  806.  
  807. bsdsocket.library/gethostbyname                bsdsocket.library/gethostbyname
  808.  
  809.    NAME
  810.         gethostbyname, gethostbyaddr  - get network host entry
  811.  
  812.    SYNOPSIS
  813.         #include <sys/types.h>
  814.         #include <sys/socket.h>
  815.         #include <netdb.h>
  816.  
  817.         hostent = gethostbyname(name)
  818.         D0                      A0
  819.  
  820.         struct hostent *gethostbyname(char *);
  821.  
  822.         hostent = gethostbyaddr(addr, len, type)
  823.         D0                      A0    D0   D1
  824.  
  825.         struct hostent *gethostbyaddr(caddr_t, LONG, LONG);
  826.  
  827.  
  828.    DESCRIPTION 
  829.         gethostbyname() and gethostbyaddr() both return a pointer
  830.         to an object with the following structure containing the
  831.         data received from a name server or the broken-out fields
  832.         of a line in netdb configuration file.  In the case of
  833.         gethostbyaddr(), addr is a pointer to the binary format
  834.         address of length len (not a character string) and type is
  835.         an address family as defined in <sys/socket.h>. 
  836.  
  837.           struct hostent {
  838.             char *h_name;       /* official name of host */
  839.             char **h_aliases;   /* alias list */
  840.             int  h_addrtype;    /* address type */
  841.             int  h_length;      /* length of address */
  842.             char **h_addr_list; /* list of addresses from name server */
  843.           };
  844.  
  845.         The members of this structure are:
  846.  
  847.         h_name              Official name of the host.
  848.  
  849.         h_aliases           A zero  terminated  array  of  alternate
  850.                             names for the host.
  851.  
  852.         h_addrtype          The  type  of  address  being  returned;
  853.                             currently always AF_INET.
  854.  
  855.         h_length            The length, in bytes, of the address.
  856.  
  857.         h_addr_list         A pointer to a list of network addresses
  858.                             for  the named host.  Host addresses are
  859.                             returned in network byte order.
  860.  
  861.    DIAGNOSTICS
  862.         A NULL pointer is returned if no matching entry was found or 
  863.         error occured.
  864.  
  865.    BUGS
  866.         All information is contained in a static area so it must  be
  867.         copied if it is to be saved.  Only the Internet address for-
  868.         mat is currently understood.
  869.  
  870.    SEE ALSO
  871.         AmiTCP/IP configuration
  872.  
  873. bsdsocket.library/getnetbyaddr                  bsdsocket.library/getnetbyaddr
  874.  
  875.    SEE ALSO
  876.         getnetbyname()
  877.  
  878. bsdsocket.library/getnetbyname                  bsdsocket.library/getnetbyname
  879.  
  880.    NAME
  881.         getnetbyname, getnetbyaddr - get network entry
  882.  
  883.    SYNOPSIS
  884.         #include <netdb.h>
  885.  
  886.         netent = getnetbyname(name)
  887.         D0                    A0
  888.  
  889.         struct netent *getnetbyname(char *);
  890.  
  891.         netent = getnetbyaddr(net, type)
  892.         D0                    D0   D1
  893.  
  894.         struct netent *getnetbyaddr(long, long);
  895.  
  896.    DESCRIPTION
  897.         getnetbyname(), and getnetbyaddr() both return  a  pointer to
  898.         an  object  with  the  following  structure  containing   the
  899.         broken-out fields of a line in netdb configuration file.
  900.  
  901.           struct netent {
  902.             char *n_name;       /* official name of net */
  903.             char **n_aliases;   /* alias list */
  904.             int  n_addrtype;    /* net number type */
  905.             long n_net;         /* net number */
  906.           };
  907.  
  908.         The members of this structure are:
  909.  
  910.         n_name              The official name of the network.
  911.  
  912.         n_aliases           A  zero  terminated  list  of  alternate
  913.                             names for the network.
  914.  
  915.         n_addrtype          The type of the network number returned;
  916.                             currently only AF_INET.
  917.  
  918.         n_net               The network number.  Network numbers are
  919.                             returned in machine byte order.
  920.  
  921.         Network numbers are supplied in host order.
  922.  
  923.         Type specifies the address type to use, currently only
  924.         AF_INET is supported.
  925.  
  926.    DIAGNOSTICS
  927.         A NULL pointer is returned if no matching entry was found or 
  928.         error occured.
  929.  
  930.    BUGS
  931.         All information is contained in a static area so it must  be
  932.         copied if it is to be saved.
  933.  
  934.         Only Internet network numbers are currently understood.
  935.  
  936.    SEE ALSO
  937.         AmiTCP/IP configuration
  938.  
  939. bsdsocket.library/getpeername                    bsdsocket.library/getpeername
  940.  
  941.    NAME
  942.         getpeername - get name of connected peer
  943.  
  944.    SYNOPSIS
  945.         success =  getpeername(s, name, namelen)
  946.         D0                     D0 A0    A1
  947.  
  948.         long getpeername(long, struct sockaddr *, long *);
  949.  
  950.    FUNCTION
  951.         getpeername() returns the name  of  the  peer  connected  to
  952.         socket  s.   The long  pointed  to  by the namelen parameter
  953.         should be  initialized  to  indicate  the  amount  of  space
  954.         pointed  to  by name.  On return it contains the actual size
  955.         of the name returned (in bytes).  The name is  truncated  if
  956.         the buffer provided is too small.
  957.  
  958.    RETURN VALUE
  959.         A 0 is returned if the call succeeds, -1 if it fails.
  960.  
  961.    ERRORS
  962.         EBADF        - The argument s is not a valid descriptor.
  963.  
  964.         ENOBUFS      - Insufficient resources were available in  the
  965.                        system to perform the operation.
  966.  
  967.         ENOTCONN     - The socket is not connected.
  968.  
  969.    SEE ALSO
  970.         accept(), bind(), getsockname(), socket()
  971. bsdsocket.library/getprotobyname              bsdsocket.library/getprotobyname
  972.  
  973.    NAME
  974.         getprotobyname, getprotobynumber - get protocol entry
  975.  
  976.    SYNOPSIS
  977.         #include <netdb.h>
  978.  
  979.         protoent = getprotobyname(name)
  980.         D0                        A0
  981.  
  982.         struct protoent *getprotobyname(char *);
  983.  
  984.         protoent = getprotobynumber(proto)
  985.         D0                          D0
  986.  
  987.         struct protoent *getprotobynumber(long);
  988.  
  989.    DESCRIPTION
  990.         getprotobyname() and getprotobynumber() both return a pointer
  991.         to  an  object with the  following structure  containing  the
  992.         broken-out fields of a line in netdb configuration file
  993.  
  994.           struct    protoent {
  995.             char *p_name;       /* official name of protocol */
  996.             char **p_aliases;   /* alias list */
  997.             int  p_proto;       /* protocol number */
  998.          };
  999.  
  1000.         The members of this structure are:
  1001.  
  1002.         p_name              The official name of the protocol.
  1003.         p_aliases           A  zero  terminated  list  of  alternate
  1004.                             names for the protocol.
  1005.         p_proto             The protocol number.
  1006.  
  1007.  
  1008.    DIAGNOSTICS
  1009.         A NULL pointer is returned if no matching entry was found or 
  1010.         error occured.
  1011.  
  1012.    BUGS
  1013.         All information is contained in a static area so it must  be
  1014.         copied  if  it  is to be saved.  Only the Internet protocols
  1015.         are currently understood.
  1016.  
  1017.    SEE ALSO
  1018.         AmiTCP/IP configuration
  1019.  
  1020. bsdsocket.library/getprotobynumber          bsdsocket.library/getprotobynumber
  1021.  
  1022.    SEE ALSO
  1023.         getprotobyname()
  1024.  
  1025. bsdsocket.library/getservbyname                bsdsocket.library/getservbyname
  1026.  
  1027.    NAME
  1028.         getservbyname, getservbyport - get service entry
  1029.  
  1030.    SYNOPSIS
  1031.         #include <netdb.h>
  1032.  
  1033.         servent = getservbyname(name, proto)
  1034.         D0                      A0    A1
  1035.  
  1036.         struct servent *getservbyname(char *, char *)
  1037.  
  1038.         servent = getservbyport(port, proto)
  1039.         D0                      D0    A0
  1040.  
  1041.         struct servent *getservbyport(long, char *);
  1042.  
  1043.    DESCRIPTION
  1044.         getservbyname() and getservbyport() both return a pointer  to
  1045.         an   object  with  the  following  structure  containing  the
  1046.         broken-out fields of a line in netdb configuration file.
  1047.  
  1048.           struct    servent {
  1049.             char *s_name;       /* official name of service */
  1050.             char **s_aliases;   /* alias list */
  1051.             int  s_port;        /* port service resides at */
  1052.             char *s_proto;      /* protocol to use */
  1053.           };
  1054.  
  1055.         The members of this structure are:
  1056.              s_name              The official name of the service.
  1057.              s_aliases           A zero terminated list of alternate
  1058.                                  names for the service.
  1059.              s_port              The port number at which  the  ser-
  1060.                                  vice  resides.   Port  numbers  are
  1061.                                  returned  in  network  short   byte
  1062.                                  order.
  1063.              s_proto             The name of  the  protocol  to  use
  1064.                                  when contacting the service.
  1065.  
  1066.         The proto argument specifies the protocol for which to the
  1067.         sercive is to use. It is a normal C string, e.g. "tcp" or
  1068.         "udp".
  1069.  
  1070.    DIAGNOSTICS
  1071.         A NULL pointer is returned if no matching entry was found or 
  1072.         error occured.
  1073.  
  1074.    BUGS
  1075.         All information is contained in a static area so it must  be
  1076.         copied  if it is to be saved.  Expecting port numbers to fit
  1077.         in a 32 bit quantity is probably naive.
  1078.  
  1079.    SEE ALSO
  1080.         AmiTCP/IP configuration
  1081.  
  1082. bsdsocket.library/getservbyport                bsdsocket.library/getservbyport
  1083.  
  1084.    SEE ALSO
  1085.         getservbyname()
  1086.  
  1087. bsdsocket.library/getsockname                    bsdsocket.library/getsockname
  1088.  
  1089.    NAME
  1090.         getsockname - get socket name
  1091.  
  1092.    SYNOPSIS
  1093.  
  1094.         success = getsockname(s, name, namelen)
  1095.         D0                    D0 A0    A1
  1096.  
  1097.         long getsockname(long, struct sockaddr *, long *);
  1098.  
  1099.    FUNCTION
  1100.         getsockname() returns the current  name  for  the  specified
  1101.         socket.   The  namelen  parameter  should  be initialized to
  1102.         indicate the amount of space pointed to by name.  On  return
  1103.         it contains the actual size of the name returned (in bytes).
  1104.  
  1105.    DIAGNOSTICS
  1106.         A 0 is returned if the call succeeds, -1 if it fails.
  1107.  
  1108.    ERRORS
  1109.         The call succeeds unless:
  1110.  
  1111.         EBADF          s is not a valid descriptor.
  1112.  
  1113.         ENOBUFS        Insufficient resources were available in  the
  1114.                        system to perform the operation.
  1115.  
  1116.    SEE ALSO
  1117.         bind(), getpeername(), socket()
  1118. bsdsocket.library/getsockopt                      bsdsocket.library/getsockopt
  1119.  
  1120.    NAME
  1121.         getsockopt, setsockopt - get and set options on sockets
  1122.  
  1123.    SYNOPSIS
  1124.         #include <sys/types.h>
  1125.         #include <sys/socket.h>
  1126.  
  1127.         success =  getsockopt(s, level, optname, optval, optlen)
  1128.         D0                    D0 D1     D2       A0      A1
  1129.         
  1130.         long getsockopt(long, long, long, caddr_t, long *);
  1131.  
  1132.         success =  setsockopt(s, level, optname, optval, optlen)
  1133.         D0                    D0 D1     D2       A0      D3
  1134.         
  1135.         long setsockopt(long, long, long, caddr_t, long);
  1136.  
  1137.    FUNCTION
  1138.         getsockopt() and setsockopt() manipulate options  associated
  1139.         with  a socket.  Options may exist at multiple protocol lev-
  1140.         els; they are always present  at  the  uppermost  ``socket''
  1141.         level.
  1142.  
  1143.         When manipulating socket options  the  level  at  which  the
  1144.         option resides and the name of the option must be specified.
  1145.         To manipulate options at  the  ``socket''  level,  level  is
  1146.         specified as SOL_SOCKET.  To manipulate options at any other
  1147.         level the protocol number of the appropriate  protocol  con-
  1148.         trolling  the  option is supplied.  For example, to indicate
  1149.         that an option is to be interpreted  by  the  TCP  protocol,
  1150.         level  should  be  set  to  the  protocol number of TCP.
  1151.  
  1152.         The parameters optval and optlen are used to  access  option
  1153.         values  for  setsockopt().  For getsockopt() they identify a
  1154.         buffer in which the value for the requested option(s) are to
  1155.         be  returned.   For  getsockopt(),  optlen is a value-result
  1156.         parameter, initially  containing  the  size  of  the  buffer
  1157.         pointed to by optval, and modified on return to indicate the
  1158.         actual size of the value returned.  If no option value is to
  1159.         be supplied or returned, optval may be supplied as 0.
  1160.  
  1161.         optname and any specified options are  passed  uninterpreted
  1162.         to  the appropriate protocol module for interpretation.  The
  1163.         include  file  <sys/socket.h>   contains   definitions   for
  1164.         ``socket'' level options, described below.  Options at other
  1165.         protocol  levels  vary  in  format  and  name.
  1166.  
  1167.         Most socket-level options take an int parameter for  optval.
  1168.         For setsockopt(), the parameter should be non-zero to enable
  1169.         a boolean option, or zero if the option is to  be  disabled.
  1170.  
  1171.         SO_LINGER   uses  a  struct  linger  parameter,  defined  in
  1172.         <sys/socket.h>, which specifies the  desired  state  of  the
  1173.         option and the linger interval (see below).
  1174.  
  1175.         The following options are recognized at  the  socket  level.
  1176.         Except  as noted, each may be examined with getsockopt() and
  1177.         set with setsockopt().
  1178.  
  1179.              SO_DEBUG          - toggle   recording   of   debugging
  1180.                                  information
  1181.              SO_REUSEADDR      - toggle local address reuse
  1182.              SO_KEEPALIVE      - toggle keep connections alive
  1183.              SO_DONTROUTE      - toggle routing bypass for  outgoing
  1184.                                  messages
  1185.              SO_LINGER         - linger on close if data present
  1186.              SO_BROADCAST      - toggle   permission   to   transmit
  1187.                                  broadcast messages
  1188.              SO_OOBINLINE      - toggle  reception  of   out-of-band
  1189.                                  data in band
  1190.              SO_SNDBUF         - set buffer size for output
  1191.              SO_RCVBUF         - set buffer size for input
  1192.              SO_TYPE           - get the type  of  the  socket  (get
  1193.                                  only)
  1194.              SO_ERROR          - get and clear error on  the  socket
  1195.                                  (get only)
  1196.  
  1197.         SO_DEBUG  enables  debugging  in  the  underlying   protocol
  1198.         modules.   SO_REUSEADDR  indicates  that  the  rules used in
  1199.         validating addresses supplied in a bind() call should allow
  1200.         reuse of local addresses.  SO_KEEPALIVE enables the periodic
  1201.         transmission of messages on a connected socket.  Should  the
  1202.         connected  party fail to respond to these messages, the con-
  1203.         nection is considered broken. If  the  process  is
  1204.         waiting in select() when the connection is broken, select()
  1205.         returns true for any read or write events selected  for  the
  1206.         socket.    SO_DONTROUTE  indicates  that  outgoing  messages
  1207.         should bypass the  standard  routing  facilities.   Instead,
  1208.         messages  are  directed to the appropriate network interface
  1209.         according to the network portion of the destination address.
  1210.  
  1211.         SO_LINGER controls the action taken when unsent messags  are
  1212.         queued  on  socket and a CloseSocket() is performed.  If the
  1213.         socket promises reliable delivery of data and  SO_LINGER  is
  1214.         set,  the  system  will  block  the  process  on the close
  1215.         attempt until it is able to transmit the data  or  until  it
  1216.         decides  it  is unable to deliver the information (a timeout
  1217.         period, in seconds, termed the linger interval, is specified
  1218.         in the set- sockopt() call when SO_LINGER is requested).  If
  1219.         SO_LINGER  is  disabled and a CloseSocket()  is  issued, the
  1220.         system will process the  close  in  a manner that allows the
  1221.         process to continue as quickly as possible.
  1222.  
  1223.         The option SO_BROADCAST requests permission to  send  broad-
  1224.         cast  datagrams  on  the socket.  Broadcast was a privileged
  1225.         operation in earlier versions of the system.  With protocols
  1226.         that  support  out-of-band  data,  the  SO_OOBINLINE  option
  1227.         requests that out-of-band data be placed in the normal  data
  1228.         input  queue  as  received;  it will then be accessible with
  1229.         recv() or read() calls without the MSG_OOB flag.   SO_SNDBUF
  1230.         and  SO_RCVBUF are options to adjust the normal buffer sizes
  1231.         allocated for output and input buffers,  respectively.   The
  1232.         buffer size may be increased for high-volume connections, or
  1233.         may be decreased to limit the possible backlog  of  incoming
  1234.         data.   The system places an absolute limit on these values.
  1235.         Finally, SO_TYPE and SO_ERROR are  options  used  only  with
  1236.         getsockopt().   SO_TYPE returns the type of the socket, such
  1237.         as SOCK_STREAM; it is useful for servers that inherit  sock-
  1238.         ets  on  startup.  SO_ERROR returns any pending error on the
  1239.         socket and clears the error status.  It may be used to check
  1240.         for asynchronous errors on connected datagram sockets or for
  1241.         other asynchronous errors.
  1242.  
  1243.    RETURN VALUES
  1244.          0 - on success.
  1245.  
  1246.         -1 - on failure and set errno to indicate the error.
  1247.  
  1248.    ERRORS
  1249.         EBADF             - s is not a valid descriptor.
  1250.  
  1251.         ENOPROTOOPT       - The option is unknown at the level indi-
  1252.                             cated.
  1253.  
  1254.    SEE ALSO
  1255.         IoctlSocket(), socket()
  1256.  
  1257.    BUGS
  1258.         Several of the socket options should  be  handled  at  lower
  1259.         levels of the system.
  1260. bsdsocket.library/inet_MakeAddr                bsdsocket.library/inet_MakeAddr
  1261.  
  1262.    SEE ALSO
  1263.        inet_addr()
  1264.  
  1265. bsdsocket.library/inet_addr                        bsdsocket.library/inet_addr
  1266.  
  1267.    NAME
  1268.         inet_addr,  inet_network,  Inet_MakeAddr,  Inet_LnaOf,
  1269.         Inet_NetOf, Inet_NtoA - Internet address manipulation
  1270.  
  1271.         inet_makeaddr, inet_lnaof, inet_netof,
  1272.         inet_ntoa -- inline/stub functions to handle structure arguments
  1273.  
  1274.    SYNOPSIS
  1275.         #include <netinet/in.h>
  1276.  
  1277.         addr = inet_addr(cp)
  1278.         D0               A0
  1279.  
  1280.         unsigned long inet_addr(char *);
  1281.  
  1282.         net = inet_network(cp)
  1283.         D0                 A0
  1284.         
  1285.         unsigned long inet_network(char *);
  1286.  
  1287.         in_addr = Inet_MakeAddr(net, lna)
  1288.         D0                      D0   D1
  1289.  
  1290.         unsigned long Inet_MakeAddr(long, long);
  1291.  
  1292.         lna = Inet_LnaOf(in)
  1293.         D0               D0
  1294.  
  1295.         long Inet_LnaOf(unsigned long);
  1296.  
  1297.         net = Inet_NetOf(in)
  1298.         D0               D0
  1299.  
  1300.         long Inet_NetOf(unsigned long);
  1301.  
  1302.         addr = Inet_NtoA(in)
  1303.         DO               D0
  1304.  
  1305.         char * Inet_NtoA(unsigned long);
  1306.  
  1307.         
  1308.         in_addr = inet_makeaddr(net, lna)
  1309.  
  1310.         struct in_addr inet_makeaddr(long, long);
  1311.  
  1312.         lna = inet_lnaof(in)
  1313.  
  1314.         int inet_lnaof(struct in_addr);
  1315.  
  1316.         net = inet_netof(in)
  1317.  
  1318.         int inet_netof(struct in_addr);
  1319.  
  1320.         addr = inet_ntoa(in)
  1321.  
  1322.         char * inet_ntoa(struct in_addr);
  1323.  
  1324.    IMPLEMENTATION NOTE
  1325.         Return  value  of  Inet_MakeAddr()  and  argument  types  of
  1326.         Inet_LnaOf(), Inet_NetOf() and Inet_NtoA() are longs instead
  1327.         of  struct  in_addr.  The original behaviour  is achieved by
  1328.         using  included  stub  functions (lower case function names)
  1329.         which handle structure arguments.
  1330.  
  1331.    DESCRIPTION
  1332.         The routines inet_addr() and inet_network()  each  interpret
  1333.         character  strings  representing  numbers  expressed  in the
  1334.         Internet standard `.' notation, returning  numbers  suitable
  1335.         for  use as Internet addresses and Internet network numbers,
  1336.         respectively.  The routine inet_makeaddr() takes an Internet
  1337.         network number and a local network address and constructs an
  1338.         Internet address from it.   The  routines  inet_netof()  and
  1339.         inet_lnaof()  break apart Internet host addresses, returning
  1340.         the network number and local network address  part,  respec-
  1341.         tively.
  1342.  
  1343.         The routine inet_ntoa() returns a pointer to a string in the
  1344.         base 256 notation ``d.d.d.d'' described below.
  1345.  
  1346.         All Internet address are returned in  network  order  (bytes
  1347.         ordered  from left to right).  All network numbers and local
  1348.         address parts are returned as machine format integer values.
  1349.  
  1350.    INTERNET ADDRESSES
  1351.         Values specified using the `.'  notation  take  one  of  the
  1352.  
  1353.         following forms:
  1354.  
  1355.              a.b.c.d
  1356.              a.b.c
  1357.              a.b
  1358.              a
  1359.  
  1360.         When four parts are specified, each is interpreted as a byte
  1361.         of data and assigned, from left to right, to  the four bytes
  1362.         of  an Internet address.  Note: when  an Internet address is
  1363.         viewed  as  a  32-bit  integer  quantity  on  little  endian
  1364.         systems,  the  bytes referred to  above appear  as  d.c.b.a.
  1365.         bytes are ordered from right to left.
  1366.  
  1367.         When a three part address is specified,  the  last  part  is
  1368.         interpreted  as  a  16-bit  quantity and placed in the right
  1369.         most two bytes of the network address.  This makes the three
  1370.         part  address  format convenient for specifying Class B net-
  1371.         work addresses as "128.net.host".
  1372.  
  1373.         When a two part address is supplied, the last part is inter-
  1374.         preted  as  a  24-bit  quantity and placed in the right most
  1375.         three bytes of the network address.  This makes the two part
  1376.         address  format  convenient  for  specifying Class A network
  1377.         addresses as "net.host".
  1378.  
  1379.         When only one part is given, the value is stored directly in
  1380.         the network address without any byte rearrangement.
  1381.  
  1382.         All numbers supplied as ``parts'' in a `.' notation  may  be
  1383.         decimal,  octal,  or  hexadecimal,  as  specified  in  the C
  1384.         language (that is, a leading 0x or 0X  implies  hexadecimal;
  1385.         otherwise,  a leading 0 implies octal; otherwise, the number
  1386.         is interpreted as decimal).
  1387.  
  1388.    RETURN VALUE
  1389.         The value -1 is returned by inet_addr()  and  inet_network()
  1390.         for malformed requests.
  1391.  
  1392.    BUGS
  1393.         The problem of host byte ordering versus network byte order-
  1394.         ing  is  confusing.  A simple way to specify Class C network
  1395.         addresses in a manner similar to that for Class B and  Class
  1396.         A is needed.
  1397.  
  1398.         The return value from inet_ntoa() points to static buffer
  1399.         which  is  overwritten  in  each inet_ntoa() call.
  1400.  
  1401. bsdsocket.library/inet_lnaof                      bsdsocket.library/inet_lnaof
  1402.  
  1403.    SEE ALSO
  1404.        inet_addr()
  1405.  
  1406. bsdsocket.library/inet_makeaddr                bsdsocket.library/inet_makeaddr
  1407.  
  1408.    SEE ALSO
  1409.        inet_addr()
  1410.  
  1411. bsdsocket.library/inet_netof                      bsdsocket.library/inet_netof
  1412.  
  1413.    SEE ALSO
  1414.        inet_addr()
  1415.  
  1416. bsdsocket.library/inet_network                  bsdsocket.library/inet_network
  1417.  
  1418.    SEE ALSO
  1419.        inet_addr()
  1420.  
  1421. bsdsocket.library/inet_ntoa                        bsdsocket.library/inet_ntoa
  1422.  
  1423.    SEE ALSO
  1424.        inet_addr()
  1425.  
  1426. bsdsocket.library/listen                              bsdsocket.library/listen
  1427.    NAME
  1428.         listen - listen for connections on a socket
  1429.  
  1430.    SYNOPSIS
  1431.         success = listen(s, backlog)
  1432.         D0               D0 D1
  1433.  
  1434.         long listen(long, long);
  1435.  
  1436.    FUNCTION
  1437.         To accept  connections,  a  socket  is  first  created  with
  1438.         socket(),  a  backlog for incoming connections is specified
  1439.         with listen() and then the  connections  are  accepted  with
  1440.         accept().   The  listen()  call  applies only to socket of
  1441.         type SOCK_STREAM.
  1442.  
  1443.         The backlog parameter defines the maximum length  the  queue
  1444.         of pending connections may grow to.  If a connection request
  1445.         arrives with the queue full the client will receive an error
  1446.         with an indication of ECONNREFUSED.
  1447.  
  1448.    RETURN VALUES
  1449.          0    on success.
  1450.  
  1451.         -1    on failure and sets errno to indicate the error.
  1452.  
  1453.    ERRORS
  1454.         EBADF             - s is not a valid descriptor.
  1455.  
  1456.         EOPNOTSUPP        - The socket is not of a  type  that  sup-
  1457.                             ports listen().
  1458.  
  1459.    SEE ALSO
  1460.         accept(), connect(), socket()
  1461.  
  1462.    BUGS
  1463.         The backlog is currently limited (silently) to 5.
  1464. bsdsocket.library/recv                                  bsdsocket.library/recv
  1465.    NAME
  1466.         recv, recvfrom, - receive a message from a socket
  1467.  
  1468.    SYNOPSIS
  1469.         #include <sys/types.h>
  1470.         #include <sys/socket.h>
  1471.  
  1472.        nbytes = recv(s, buf, len, flags)
  1473.        D0            D0 A0   D1   D2
  1474.  
  1475.        long recv(long, char *, long, long);
  1476.  
  1477.        nbytes = recvfrom(s, buf, len, flags, from, fromlen)
  1478.        D0                D0 A0   D1   D2     A1    A2
  1479.  
  1480.        long recvfrom(long, char *, long, long, 
  1481.                         struct sockaddr *, long *);
  1482.  
  1483.    FUNCTION
  1484.         s is a socket created with socket().  recv() and recvfrom(),
  1485.         are used  to  receive messages from  another socket.  recv()
  1486.         may  be  used  only on a connected socket  (see  connect()),
  1487.         while  recvfrom() may be used  to receive data  on a  socket
  1488.         whether it is in a connected state or not.
  1489.  
  1490.         If from is not a NULL pointer, the  source  address  of  the
  1491.         message  is filled in.  fromlen is a value-result parameter,
  1492.         initialized to the size of the buffer associated with  from,
  1493.         and  modified  on  return to indicate the actual size of the
  1494.         address  stored  there.   The  length  of  the  message   is
  1495.         returned.   If  a message is too long to fit in the supplied
  1496.         buffer, excess bytes may be discarded depending on the  type
  1497.         of socket the message is received from (see socket()).
  1498.  
  1499.         If no messages are available at the socket, the receive call
  1500.         waits  for  a  message  to arrive, unless the socket is non-
  1501.         blocking (see IoctlSocket()) in which case -1  is  returned
  1502.         with the external variable errno set to EWOULDBLOCK.
  1503.  
  1504.         The select() call may be used to determine when  more  data
  1505.         arrive.
  1506.  
  1507.         The flags parameter is formed by ORing one or  more  of  the
  1508.         following:
  1509.  
  1510.         MSG_OOB      - Read any "out-of-band" data  present  on  the
  1511.                        socket,  rather  than  the  regular "in-band"
  1512.                        data.
  1513.  
  1514.         MSG_PEEK     - "Peek" at the data present on the socket; the
  1515.                        data  are returned, but not consumed, so that
  1516.                        a subsequent receive operation will  see  the
  1517.                        same data.
  1518.  
  1519.    RETURN VALUES
  1520.         These calls return the number of bytes received, or -1 if an
  1521.         error occurred.
  1522.  
  1523.    ERRORS
  1524.         EBADF             - s is an invalid descriptor.
  1525.  
  1526.         EINTR             - The operation was interrupted by a break 
  1527.                             signal.
  1528.  
  1529.         EWOULDBLOCK       - The socket is  marked  non-blocking  and
  1530.                             the requested operation would block.
  1531.  
  1532.    SEE ALSO
  1533.         connect(), getsockopt(), IoctlSocket(), select(), send(),
  1534.         SetSocketSignals(), socket()
  1535. bsdsocket.library/recvfrom                          bsdsocket.library/recvfrom
  1536.  
  1537.    SEE ALSO
  1538.         recv()
  1539. bsdsocket.library/select                              bsdsocket.library/select
  1540.  
  1541.    NAME
  1542.         select -- synchronous I/O multiplexing (stub/inline function)
  1543.         WaitSelect -- select() with Amiga Wait() function.
  1544.  
  1545.    SYNOPSIS
  1546.         #include <sys/types.h>
  1547.         #include <sys/time.h>
  1548.  
  1549.         n = select (nfds, readfds, writefds, exceptfds, timeout)
  1550.  
  1551.         long select(long, fd_set *, fd_set *, fd_set *, 
  1552.                     struct timeval *);
  1553.  
  1554.         n = WaitSelect (nfds, readfds, writefds, exceptfds, timeout,
  1555.         D0              D0    A0       A1        A2         A3
  1556.                     sigmp)
  1557.                     D1
  1558.  
  1559.         long WaitSelect(long, fd_set *, fd_set *, fd_set *, 
  1560.                         struct timeval *, long *);
  1561.  
  1562.         FD_SET (fd, &fdset)
  1563.         FD_CLR (fd, &fdset)
  1564.         FD_ISSET (fd, &fdset)
  1565.         FD_ZERO (&fdset)
  1566.         long fd;
  1567.         fd_set fdset;
  1568.  
  1569.    DESCRIPTION
  1570.         select() examines the socket descriptor sets whose addresses
  1571.         are passed in readfds,  writefds,  and exceptfds  to  see if
  1572.         some of their descriptors are ready  for reading,  ready for
  1573.         writing,  or have an exceptional condition pending.  nfds is
  1574.         the  number  of bits to be checked in  each  bit  mask  that
  1575.         represent a file descriptor; the descriptors from 0  through
  1576.         (nfds - 1) in the descriptor sets  are examined.  On return,
  1577.         select()  replaces  the  given descriptor sets  with subsets
  1578.         consisting of  those descriptors  that  are  ready  for  the
  1579.         requested operation.  The total number  of ready descriptors
  1580.         in all the sets is returned.
  1581.  
  1582.         WaitSelect() also takes a signal mask which is waited during
  1583.         normal select() operation. If one of these singals is recei-
  1584.         ved,  WaitSelect() returns  and has  re-set  the signal mask
  1585.         to return those signals that  have arrived.  Normal select()
  1586.         return values are returned.
  1587.  
  1588.         The descriptor sets are stored as bit fields  in  arrays  of
  1589.         integers.   The following macros are provided for manipulat-
  1590.         ing such descriptor sets:  FD_ZERO  (&fdset)  initializes  a
  1591.         descriptor  set  fdset to the null set.  FD_SET(fd, &fdset )
  1592.         includes a particular descriptor fd  in  fdset.   FD_CLR(fd,
  1593.         &fdset)  removes  fd  from  fdset.   FD_ISSET(fd, &fdset) is
  1594.         nonzero if fd is a member of  fdset,  zero  otherwise.   The
  1595.         behavior  of these macros is undefined if a descriptor value
  1596.         is less than zero or greater than or  equal  to  FD_SETSIZE,
  1597.         which  is  normally  at least equal to the maximum number of
  1598.         descriptors supported by the system.
  1599.  
  1600.         If timeout is not a NULL pointer,  it  specifies  a  maximum
  1601.         interval  to wait for the selection to complete.  If timeout
  1602.         is a NULL  pointer,  the  select  blocks  indefinitely.   To
  1603.         effect  a  poll,  the  timeout argument should be a non-NULL
  1604.         pointer, pointing to a zero-valued timeval structure.
  1605.  
  1606.         Any of readfds, writefds, and exceptfds may be given as NULL
  1607.         pointers if no descriptors are of interest.
  1608.  
  1609.         Selecting true for reading on a socket descriptor upon which
  1610.         a  listen() call has been performed indicates that a subse-
  1611.         quent accept() call on that descriptor will not block.
  1612.  
  1613.    RETURN VALUES
  1614.         select() returns a non-negative value on success. A positive
  1615.         value indicates the number of ready descriptors in the
  1616.         descriptor sets. 0 indicates that the time limit referred to
  1617.         by timeout expired or that the operation was interrupted
  1618.         either by a break signal or by arrival of a signal specified
  1619.         in *sigmp. On failure, select() returns -1, sets errno to
  1620.         indicate the error, and the descriptor sets are not changed.
  1621.  
  1622.    ERRORS
  1623.         EBADF        - One  of  the  descriptor  sets  specified  an
  1624.                        invalid descriptor.
  1625.  
  1626.         EINTR        - one of the signals in SIGINTR  mask (see Set-
  1627.                        SocketSignals())   is  set  and  it  was  not
  1628.                        requested in WaitSelect() call.
  1629.  
  1630.         EINVAL       - A component of the pointed-to time  limit  is
  1631.                        outside  the  acceptable range: t_sec must be
  1632.                        between 0 and 10^8, inclusive. t_usec must be
  1633.                        greater  than  or  equal  to 0, and less than
  1634.                        10^6.
  1635.  
  1636.    SEE ALSO
  1637.         accept(),  connect(), getdtablesize(), listen(), recv(),
  1638.         send(), SetDTableSize(), SetSocketSignals()
  1639.  
  1640.    NOTES
  1641.         Under rare  circumstances,  select()  may  indicate  that  a
  1642.         descriptor  is  ready for writing when in fact an attempt to
  1643.         write would block.  This  can  happen  if  system  resources
  1644.         necessary  for  a  write are exhausted or otherwise unavail-
  1645.         able.  If an application deems it critical that writes to  a
  1646.         file  descriptor not block, it should set the descriptor for
  1647.         non-blocking I/O using the FIOASYNC request to IoctlSocket().
  1648.  
  1649.         Default   system   limit  for  open  socket  descriptors  is
  1650.         currently  64. However,  in  order  to accommodate  programs
  1651.         which might  potentially  use  a larger number of open files
  1652.         with select, it is possible  to  increase this size within a
  1653.         program  by  providing  a  larger definition  of  FD_SETSIZE
  1654.         before    the   inclusion    of   <sys/types.h>    and   use
  1655.         SetDTableSize(FD_SETSIZE) call directly after OpenLibrary().
  1656.  
  1657.    BUGS
  1658.         select() should probably return the time remaining from  the
  1659.         original  timeout,  if  any,  by modifying the time value in
  1660.         place.  This may be implemented in future  versions  of  the
  1661.         system.   Thus,  it  is  unwise  to  assume that the timeout
  1662.         pointer will be unmodified by the select() call.
  1663. bsdsocket.library/send                                  bsdsocket.library/send
  1664.  
  1665.    NAME
  1666.         send, sendto - send a message from a socket
  1667.  
  1668.    SYNOPSIS
  1669.         #include <sys/types.h>
  1670.         #include <sys/socket.h>
  1671.  
  1672.         nbytes = send(s, msg, len, flags)
  1673.         D0            D0 A0   D1   D2
  1674.  
  1675.         int send(int, char *, int, int);
  1676.  
  1677.         nbytes = sendto(s, msg, len, flags, to, tolen)
  1678.         D0              D0 A0   D1   D2     A1  D3
  1679.  
  1680.         int send(int, char *, int, int, struct sockaddr *, int);
  1681.  
  1682.    FUNCTION
  1683.         s is a socket created with socket().  send() and sendto() are
  1684.         used  to transmit a message to  another socket. send() may be
  1685.         used  only when the socket  is  in a connected  state,  while
  1686.         sendto() may be used at any time.
  1687.  
  1688.         The address of the target  is given by to with tolen specify-
  1689.         ing its size.  The length of the message is given by len.  If
  1690.         the  message is  too  long  to  pass  atomically  through the
  1691.         underlying protocol, then the error EMSGSIZE is returned, and
  1692.         the message is not transmitted.
  1693.  
  1694.         No indication of failure to deliver is implicit  in a send().
  1695.         Return values of -1 indicate some locally detected errors.
  1696.  
  1697.         If no buffer space is  available at the socket  to  hold  the
  1698.         message  to  be  transmitted,  then  send() normally  blocks,
  1699.         unless the  socket  has been placed in non-blocking I/O mode.
  1700.         The select() call may be used to determine when  it  is  pos-
  1701.         sible to send more data.
  1702.  
  1703.         The flags parameter is formed  by ORing  one  or  more of the
  1704.         following:
  1705.  
  1706.         MSG_OOB           - Send  ``out-of-band''  data  on  sockets
  1707.                             that  support this notion.  The underly-
  1708.                             ing protocol must  also  support  ``out-
  1709.                             of-band''    data.     Currently,   only
  1710.                             SOCK_STREAM  sockets  created   in   the
  1711.                             AF_INET  address  family support out-of-
  1712.                             band data.
  1713.  
  1714.         MSG_DONTROUTE     - The SO_DONTROUTE option is turned on for
  1715.                             the  duration of the operation.  This is
  1716.                             usually used only by diagnostic or rout-
  1717.                             ing programs.
  1718.  
  1719.    RETURN VALUES
  1720.         On success, these functions return the number of bytes sent.
  1721.         On  failure,  they  return  -1 and set errno to indicate the
  1722.         error.
  1723.  
  1724.    ERRORS
  1725.         EBADF             - s is an invalid descriptor.
  1726.  
  1727.         EINTR             - The operation was interrupted by a break 
  1728.                              signal.
  1729.  
  1730.         EINVAL            - len is not the size of a  valid  address
  1731.                             for the specified address family.
  1732.  
  1733.         EMSGSIZE          - The socket requires that message be sent
  1734.                             atomically,  and the size of the message
  1735.                             to be sent made this impossible.
  1736.  
  1737.         ENOBUFS           - The system was  unable  to  allocate  an
  1738.                             internal   buffer.   The  operation  may
  1739.                             succeed when buffers become available.
  1740.  
  1741.         ENOBUFS           - The output queue for a network interface
  1742.                             was full.  This generally indicates that
  1743.                             the interface has stopped  sending,  but
  1744.                             may be caused by transient congestion.
  1745.  
  1746.         EWOULDBLOCK       - The socket is  marked  non-blocking  and
  1747.                             the requested operation would block.
  1748.  
  1749.    SEE ALSO
  1750.         connect(), getsockopt(), recv(), select(), socket()
  1751. bsdsocket.library/sendto                              bsdsocket.library/sendto
  1752.  
  1753.    SEE ALSO
  1754.         send()
  1755. bsdsocket.library/setsockopt                      bsdsocket.library/setsockopt
  1756.  
  1757.    SEE ALSO
  1758.         getsockopt()
  1759. bsdsocket.library/shutdown                          bsdsocket.library/shutdown
  1760.  
  1761.    NAME
  1762.         shutdown - shut down part of a full-duplex connection
  1763.  
  1764.    SYNOPSIS
  1765.         success = shutdown(s, how)
  1766.         D0                 D0 D1
  1767.  
  1768.         long shutdown(long, long);
  1769.  
  1770.    DESCRIPTION
  1771.         The shutdown() call causes all or part of a full-duplex con-
  1772.         nection on the socket associated with s to be shut down.  If
  1773.         how is 0, then further receives will be disallowed.  If  how
  1774.         is  1,  then further sends will be disallowed.  If how is 2,
  1775.         then further sends and receives will be disallowed.
  1776.  
  1777.    RETURN VALUES
  1778.          0 - on success.
  1779.  
  1780.         -1 - on failure and sets errno to indicate the error.
  1781.  
  1782.    ERRORS
  1783.         EBADF        - s is not a valid descriptor.
  1784.  
  1785.         ENOTCONN     - The specified socket is not connected.
  1786.  
  1787.    SEE ALSO
  1788.         connect(), socket()
  1789.  
  1790.    BUGS
  1791.         The how values should be defined constants.
  1792. bsdsocket.library/socket                              bsdsocket.library/socket
  1793.  
  1794.    NAME
  1795.         socket - create an endpoint for communication
  1796.  
  1797.    SYNOPSIS
  1798.         #include <sys/types.h>
  1799.         #include <sys/socket.h>
  1800.  
  1801.         s = socket(domain, type, protocol)
  1802.         D0          D0     D1    D2
  1803.  
  1804.         long socket(long, long, long);
  1805.  
  1806.    FUNCTION
  1807.         socket() creates an endpoint for communication and returns a
  1808.         descriptor.
  1809.  
  1810.         The  domain  parameter  specifies  a  communications  domain
  1811.         within which communication will take place; this selects the
  1812.         protocol  family  which should be used.  The protocol family
  1813.         generally  is  the  same  as  the  address  family  for  the
  1814.         addresses supplied in later operations on the socket.  These
  1815.         families  are defined  in the  include file  <sys/socket.h>.
  1816.         The currently understood formats are
  1817.  
  1818.                 PF_INET - (ARPA Internet protocols)
  1819.  
  1820.         The socket has the indicated type, which specifies the
  1821.         semantics of communication.  Currently defined types are:
  1822.  
  1823.                 SOCK_STREAM
  1824.                 SOCK_DGRAM
  1825.                 SOCK_RAW
  1826.  
  1827.         A  SOCK_STREAM type  provides  sequenced,  reliable, two-way
  1828.         connection  based   byte  streams.    An   out-of-band  data
  1829.         transmission  mechanism  may  be  supported.   A  SOCK_DGRAM
  1830.         socket supports datagrams  (connectionless, unreliable  mes-
  1831.         sages  of  a  fixed   (typically   small)  maximum  length).
  1832.         SOCK_RAW   sockets   provide  access  to   internal  network
  1833.         interfaces.
  1834.  
  1835.         The protocol specifies a particular protocol to be used with
  1836.         the socket.  Normally  only a single protocol exists to sup-
  1837.         port a particular socket type  within a given  protocol fam-
  1838.         ily.  However, it is possible that many protocols may exist,
  1839.         in which case a  particular protocol  must be  specified  in
  1840.         this manner.  The  protocol number to use  is  particular to
  1841.         the "communication domain" in which communication is to take
  1842.         place.
  1843.  
  1844.         Sockets of type SOCK_STREAM  are  full-duplex byte  streams,
  1845.         similar to pipes.   A  stream socket must be in  a connected
  1846.         state before any data may be sent or received on it.  A con-
  1847.         nection  to another socket is created with a connect() call.
  1848.         Once  connected, data  may be  transferred using send()  and
  1849.         recv()  or their variant calls.   When  a  session  has been
  1850.         completed a CloseSocket()  may  be  performed.   Out-of-band
  1851.         data may also  be transmitted  as  described  in  send() and
  1852.         received as described in recv().
  1853.  
  1854.         The communications protocols used to implement a SOCK_STREAM
  1855.         insure that data is  not lost or  duplicated.  If a piece of
  1856.         data for  which the peer protocol has buffer space cannot be
  1857.         successfully transmitted within a reasonable length of time,
  1858.         then the  connection  is  considered broken  and  calls will
  1859.         indicate an error with -1 returns and with ETIMEDOUT  as the
  1860.         specific error code (see Errno()).  The protocols optionally
  1861.         keep sockets "warm" by  forcing transmissions roughly  every
  1862.         minute in the absence of other activity.
  1863.  
  1864.         SOCK_DGRAM  and SOCK_RAW sockets allow sending of  datagrams
  1865.         to  correspondents  named in send()  calls.   Datagrams  are
  1866.         generally  received  with  recv(), which  returns  the  next
  1867.         datagram with its return address.
  1868.  
  1869.         The operation of  sockets  is  controlled  by  socket  level
  1870.         options.   These  options  are defined in the file socket.h.
  1871.         getsockopt() and  setsockopt()  are  used  to  get  and  set
  1872.         options, respectively.
  1873.  
  1874.    RETURN VALUES
  1875.         socket() returns a non-negative descriptor on  success.   On
  1876.         failure, it returns -1 and sets errno to indicate the error.
  1877.  
  1878.    ERRORS
  1879.         EACCES          - Permission to create  a  socket  of  the
  1880.                           specified   type   and/or   protocol  is
  1881.                           denied.
  1882.  
  1883.         EMFILE          - The per-process descriptor table is
  1884.                           full.
  1885.  
  1886.         ENOBUFS         - Insufficient buffer space is available.
  1887.                           The socket cannot be created until suf-
  1888.                           ficient resources are freed.
  1889.  
  1890.         EPROTONOSUPPORT - The protocol type or the specified  pro-
  1891.                           tocol is not supported within this
  1892.                           domain.
  1893.  
  1894.         EPROTOTYPE      - The protocol is the wrong type for the
  1895.                           socket.
  1896.  
  1897.    SEE ALSO
  1898.         accept(), bind(), CloseSocket(), connect(), getsockname(),
  1899.         getsockopt(), IoctlSocket(), listen(), recv(), select(), 
  1900.         send(), shutdown(), WaitSelect()
  1901.